<?php

class Admin extends CI_Controller {

    public function index() {
        $template_data['title'] = "Acceso autorizado";
        $template_data['content'] = $this->load->view('admin/index', array(), True);

        $this->load->view('templates/main', $template_data);
    }

    public function home() {
        $menu_data['menu'] = 'Home';
        $template_data['menu'] = $this->load->view('admin/menu', $menu_data, TRUE);

        $content_data['msg'] = "Welcome, dear registered user! Now, you are logged in... ";
        $template_data['content'] = $this->load->view('admin/home', $content_data, TRUE);

        $this->load->view('templates/template', $template_data);

        /* // Authetication succeed, go to private area
          $template_data['title'] = 'Sesión iniciada';
          //   $template_data['content'] = $this->load->view('common/home', array(), True);
          $this->load->view('templates/template', $template_data); */
    }
	
	public function list_users($pag = 1){
		
		$this->load->model('user');
		$us_por_pag = 5;
		$qtd_users = $this->user->count_users();
        
        $num_pag = intval($qtd_users / $us_por_pag) + 1;

        $min = ($pag - 1) * $us_por_pag;
        $max = $us_por_pag;
        if ($num_pag >= 1) {
            $pager = $this->load->view('templates/pager', array("pag" => $pag, "num_pag" => $num_pag), TRUE);
        } else {
            $pager = "";
        }
		
		$lista = $this->user->list_users();
		
		$menu_data['menu'] = 'Users List';
	
		$template_data['menu'] = $this->load->view('admin/menu', $menu_data, TRUE);
		$template_data['notification'] = "User deleted succesfully";
		$template_data['content'] = $this->load->view('admin/list_users', array("lista" => $this->user->list_users(),"pager" => $pager), TRUE);     
		
		$this->load->view('templates/template', $template_data);
	}

}

?>
